<template>
  <div class="two-five-rate">
    <el-table :data="rateData" border style="width: 100%">
      <el-table-column prop="className" label="班级" width="120" />
      <el-table-column prop="submittedCount" label="提交人数" width="120" />
      <el-table-column prop="maxScore" label="最高分" width="100" />
      <el-table-column prop="minScore" label="最低分" width="100" />
      
      <!-- 平均分组 -->
      <el-table-column label="平均分">
        <el-table-column prop="objectiveAverage" label="客观题" />
        <el-table-column prop="subjectiveAverage" label="主观题" />
        <el-table-column prop="totalAverage" label="全体" />
        <el-table-column prop="totalRank" label="全体排名" />
      </el-table-column>
      
      <!-- 五率统计 -->
      <el-table-column label="满分">
        <el-table-column prop="rateStats.fullScoreCount" label="人数" />
        <el-table-column prop="rateStats.fullScoreRate" label="占比" />
      </el-table-column>
      <el-table-column label="优秀">
        <el-table-column prop="rateStats.excellentCount" label="人数" />
        <el-table-column prop="rateStats.excellentRate" label="占比" />
      </el-table-column>
      <el-table-column label="良好">
        <el-table-column prop="rateStats.goodCount" label="人数" />
        <el-table-column prop="rateStats.goodRate" label="占比" />
      </el-table-column>
      <el-table-column label="及格">
        <el-table-column prop="rateStats.passCount" label="人数" />
        <el-table-column prop="rateStats.passRate" label="占比" />
      </el-table-column>
      <el-table-column label="低分">
        <el-table-column prop="rateStats.lowScoreCount" label="人数" />
        <el-table-column prop="rateStats.lowScoreRate" label="占比" />
      </el-table-column>
      
      <!-- 超均比均 -->
      <el-table-column prop="aboveAverageRate" label="超均" />
      <el-table-column prop="scoreRate" label="得分率" />
    </el-table>
  </div>
</template>

<script>
export default {
  name: 'TwoFiveRateTable',
  data() {
    return {
      rateData: []
    }
  },
  methods: {
    async fetchData(examId) {
      try {
        const response = await this.axios.get(`/api/school-work/overview/${examId}`);
        this.rateData = response.data;
      } catch (error) {
        console.error('获取两分五率数据失败:', error);
        this.$message.error('获取数据失败');
      }
    }
  },
  mounted() {
    // 获取路由参数中的examId
    const examId = this.$route.params.examId;
    this.fetchData(examId);
  }
}
</script>

<style scoped>
.two-five-rate {
  margin: 20px;
}
</style> 